
from whiff.resources import inMemorySession
from whiff import resolver
from whiff.middleware import displayTraceback
import gfChat
import gfChat.chatLogic

sessionFinder = inMemorySession.memorySessionFinder(timeout=600) # 10 minute timeout

testapp = resolver.moduleRootApplication("/", gfChat,
                                         #exception_middleware=None,
                                         exception_middleware=displayTraceback.__middleware__,
                                         on_not_found=None, # show traceback (could comment)
                                         )

testapp.registerResourceFinder(prefix="session", finder=sessionFinder)

if __name__=="__main__":
    import wsgiref.simple_server
    print "now initializing test database"
    gfChat.chatLogic.test_with_gadfly(prefix="TESTgf")
    print
    print "gadfly chat test page at http://localhost:8888/gfChatRoom"
    print "gadfly double chat test page at http://localhost:8888/catdog"
    print "mySql chat test page at http://localhost:8888/mySqlChatRoom"
    print "both of these pages may require configuration changes before they start working :)"
    print
    print "serving wsgi chat gadfly test at 8888"
    srv = wsgiref.simple_server.make_server('localhost', 8888, testapp)
    srv.serve_forever()
                    
